<?xml version="1.0"?>
<!--
    ExcepGen: TestNG failure report
    This file is part of ExcepGen.
    Copyright (c) 2008, 2009, Iparelan Solutions, LLC. All rights reserved.

    ExcepGen is free software: you can redistribute it and/or modify it under
    the terms of the GNU Lesser General Public License as published by the
    Free Software Foundation, either version 3 of the License, or (at your
    option) any later version.

    ExcepGen is distributed in the hope that it will be useful, but WITHOUT
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
    more details.

    You should have received a copy of the GNU Lesser General Public License
    along with ExcepGen. If not, see <http://www.gnu.org/licenses/>.

    author: Greg Mattes
    version: July 2008
-->

<!--
    This style sheet transforms a TestNG failure report into an Emacs style report.
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:param name="unit-test-source.dir"/>
    <xsl:param name="file.separator"/>

    <xsl:template match="*|/">
        <xsl:apply-templates select="suite/test/classes/class"/>
    </xsl:template>

    <xsl:template match="class">
        <xsl:apply-templates select="methods/include">
            <xsl:with-param name="classname" select="@name"/>
        </xsl:apply-templates>
    </xsl:template>

    <!--
        Generates an Emacs style error message with an absolute path and test
        case name. The position of line 1 and column 0 is hardcoded because
        exact position is not available.
    -->
    <xsl:template match="include">
        <xsl:param name="classname"/>
        <xsl:variable name="path-prefix" select="concat($unit-test-source.dir, $file.separator)"/>
        <xsl:variable name="slashify"    select="translate($classname, '.', $file.separator)"/>
        <xsl:variable name="source-file" select="concat($slashify, '.java')"/>
        <xsl:variable name="position"    select="':1:0:'"/>
        <xsl:variable name="message"     select="concat('FAIL: ', @name)"/>
        <xsl:value-of select="concat($path-prefix, $source-file, $position, $message)"/>
        <xsl:text>
</xsl:text> <!-- DO NOT INDENT THIS LINE: it generates a newline without indenting -->
    </xsl:template>
</xsl:stylesheet>
